package com.hejielife.immutable2;

/**
 * 2019年8月2日 上午11:00:20
 * 
 * @author hejielife
 * @despribe 线程安全的line
 */
public class Line {
	private final Point startPoint;
	private final Point endPoint;

	public Line(int startx, int starty, int endx, int endy) {
		this.startPoint = new Point(startx, starty);
		this.endPoint = new Point(endx, endy);
	}

	// 参数的改变，不会影响线
	public Line(Point startPoint, Point endPoint) {
		this.startPoint = new Point(startPoint.x, startPoint.y);
		this.endPoint = new Point(endPoint.x, endPoint.y);
	}

	public int getStartX() {
		return startPoint.x;
	}

	public int getStartY() {
		return startPoint.y;
	}

	public int getEndX() {
		return endPoint.x;
	}

	public int getEndY() {
		return endPoint.y;
	}

	public String toString() {
		return "[ Line: " + startPoint + "-" + endPoint + " ]";
	}
}
